package com.smarthealthring.mm.widgets;

import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;

/**
 * Created by hewei26 on 2017/7/5.
 */

public class SwipeRefresh extends SwipeRefreshLayout
{
    private boolean mMeasured = false;
    private boolean mRefresh = false;

    public SwipeRefresh(Context context)
    {
        super(context);
    }

    public SwipeRefresh(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }

    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
    {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        if (!mMeasured) {
            mMeasured = true;
            setRefreshing(mRefresh);
        }

    }

    @Override
    public void setRefreshing(boolean refreshing)
    {
        if (mMeasured) {
            super.setRefreshing(refreshing);
        }
        else{
            mRefresh = refreshing;
        }
    }
}
